from my_sklearn import load_iris, train_test_split, SimpleMyKNeighborsClassifier

# 加载数据
iris = load_iris()
# 分离属性和标签
X = iris.data
y = iris.target

# 分离训练集和测试集
X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.8, random_state=1)

# 邻居数量
n_neighbors = 5

# 定义 简单 KNN 算法 对象
knn = SimpleMyKNeighborsClassifier(n_neighbors=n_neighbors)
# 训练分类器
knn.fit(X_train, y_train)
# 预测
y_pred = knn.predict(X_test)

# 输出
print('自己实现的预测')
print("y_pred", y_pred)
print("y_test", y_test)
